<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>JS 基础语法</title>
</head>
<body>
    
    <script>
        var x;//函数作用域（var尽量少用）
        let y=5;//块级作用域
        const PI=3.14;
        console.log(x,y,PI)
        let name='Sam';
        console.log(name);
        let empty_value=null;
        console.log(empty_value);
        //undefined:已声明但未赋值，未来可能有值 null:没有对象值
        

        //条件语句
        let age=18;
        if(age>=18)
        {
            console.log("你已经成年了");
        }
        else
        {
            console.log("未成年");
        }

        let time=22;
        if(time<=12)
        {
            alert('上午好');
        }
        else if(time<18)
        {
            alert('下午好')
        }
        else
        {
            alert('晚上好')
        }


        //循环语句
        console.log('for循环');
        for(let i=1;i<11;i++)
        {
            console.log(i);
        }

        console.log('while循环');
        let count=1;
        while(count<=10)
        {
            console.log(count);
            count++;
        }

        //break和continue
        console.log('break和continue');
        for(var i=0;i<10;i++)
        {
            if(i==2)
            {
                continue;
            }
            if(i==6)
            {
                break;
            }
            console.log(i);
        }
    </script>
</body>
</html>